home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
BEZIERCU.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
2KB
|
73 lines
IMPLEMENTATION MODULE BezierCurve;
IMPORT Diverses, MathLib0, MagicSys;
PROCEDURE ComputeBezier(VAR BezierArray : ARRAY OF INTEGER;
P, X1, Y1, X2, Y2, X3, Y3 : INTEGER;
VAR minX, minY, maxX, maxY : INTEGER);
VAR t : INTEGER;
T, sc, xa, ya, xb, yb, x1, y1 : LONGREAL;
BEGIN
(* Algorithmus nach dem Omicron-Basic-Prg. DRAWTEX *)
sc := MathLib0.real(P);
x1 := MathLib0.real(X1);
y1 := MathLib0.real(Y1);
xb := MathLib0.real((X2-X1) * 2);
xa := (MathLib0.real(X3-X1)-xb) / sc;
yb := MathLib0.real((Y2-Y1) * 2);
ya := (MathLib0.real(Y3-Y1)-yb) / sc;
BezierArray[0] := X1; BezierArray[1] := Y1;
maxX := X1; maxY := Y1;
minX := X1; minY := Y1;
t := 1;
WHILE (t<=P) DO
T := MathLib0.real(t);
BezierArray [2*t ] := Diverses.round(x1 + ((xa*T+xb) * T / sc));
BezierArray [2*t+1] := Diverses.round(y1 + ((ya*T+yb) * T / sc));
maxX := Diverses.max(maxX, BezierArray[2*t]);
minX := Diverses.min(minX, BezierArray[2*t]);
maxY := Diverses.max(maxY, BezierArray[2*t+1]);
minY := Diverses.min(minY, BezierArray[2*t+1]);
t := t + 1;
END (* while *);
END ComputeBezier;
PROCEDURE ComputeRealBezier
(VAR BezierArray : ARRAY OF LONGREAL;
P, X1, Y1, X2, Y2, X3, Y3 : INTEGER);
VAR t : INTEGER;
T, sc, xa, ya, xb, yb, x1, y1 : LONGREAL;
BEGIN
(* Algorithmus nach dem Omicron-Basic-Prg. DRAWTEX *)
sc := MathLib0.real(P);
x1 := MathLib0.real(X1);
y1 := MathLib0.real(Y1);
xb := MathLib0.real((X2-X1) * 2);
xa := (MathLib0.real(X3-X1)-xb) / sc;
yb := MathLib0.real((Y2-Y1) * 2);
ya := (MathLib0.real(Y3-Y1)-yb) / sc;
BezierArray[0] := x1;
BezierArray[1] := y1;
t := 1;
WHILE (t<=P) DO
T := MathLib0.real(t);
BezierArray [2*t ] := x1 + ((xa*T+xb) * T / sc);
BezierArray [2*t+1] := y1 + ((ya*T+yb) * T / sc);
t := t + 1;
END (* while *);
END ComputeRealBezier;
END BezierCurve.